local hx__jisuan = fk.CreateSkill {
  name = "hx__jisuan",
  tags = { Skill.Compulsory },
}
hx__jisuan:addEffect(fk.CardUsing, {
  mute = true,
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__jisuan.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(hx__jisuan.name)
    player.room:doAnimate("InvokeSkill", {
      name = "hx__jisuan",
      player = player.id,
      skill_type = "special",
    })
    local zishu = Fk:translate(data.card.trueName, "zh_CN"):len()
    local num = data.card.number
    local x = math.max(num-zishu, 1)
    if room:askToSkillInvoke(player, { skill_name = hx__jisuan.name, prompt = "点确定令你使用的下一张牌不计次数限制且额外结算"..x.."次、伤害各+"..x.."，取消则摸"..x.."张牌" }) then
      room:addPlayerMark(player, "@hx__jisuan", x)
    else
      player:drawCards( x , hx__jisuan.name)
    end
  end,
})

hx__jisuan:addEffect(fk.CardResponding, {
  mute = true,
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__jisuan.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(hx__jisuan.name)
    player.room:doAnimate("InvokeSkill", {
      name = "hx__jisuan",
      player = player.id,
      skill_type = "special",
    })
    local zishu = Fk:translate(data.card.trueName, "zh_CN"):len()
    local num = data.card.number
    local x = math.max(num-zishu, 1)
    if room:askToSkillInvoke(player, { skill_name = hx__jisuan.name, prompt = "点确定令你使用的下一张牌不计次数限制且额外结算"..x.."次、伤害各+"..x.."，取消则摸"..x.."张牌" }) then
      room:addPlayerMark(player, "@hx__jisuan", x)
    else
      player:drawCards( x , hx__jisuan.name)
    end
  end,
})

hx__jisuan:addEffect("targetmod", {
  name = "hx__jisuan",
  bypass_times = function(self, player, skill, scope, card)
    return card and player:getMark("@hx__jisuan") > 0
  end,
})

hx__jisuan:addEffect(fk.PreCardUse, {
  is_delay_effect = true,
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(hx__jisuan.name) then
      return player:getMark("@hx__jisuan") > 0
    end
  end,
  on_use = function (self, event, target, player, data)
    local x = player:getMark("@hx__jisuan")
    data.additionalEffect = (data.additionalEffect or 0) + x
    data.additionalDamage = (data.additionalDamage or 0) + x
    player.room:setPlayerMark(player, "@hx__jisuan", 0)
  end,
})


return hx__jisuan